import 'package:get/get.dart';
import 'package:nft_shop/box/conteroller/box_controller.dart';
import 'package:nft_shop/market/conteroller/market_conteroller.dart';
import 'package:nft_shop/my/conteroller/my_conteroller.dart';
import 'package:nft_shop/sift/conteroller/sift_conteroller.dart';

class IndexConteroller extends GetxController {
  static final String TabbarItemWidget = 'TabbarItemWidget';
  //默认选中
  int selectTab = 0;

  static IndexConteroller get to => Get.find<IndexConteroller>();

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    Get.lazyPut(()=>SiftConteroller());
    Get.lazyPut(()=>MarketConteroller());
    Get.lazyPut(()=>BoxConteroller());
    Get.lazyPut(()=>MyConteroller());
    //初始化数据
    SiftConteroller.to.getDataList();
  }
  //切换tabbar
  void changeTab(int value){
    print("切换tabbar----$value");
    selectTab = value;
    if(value == 0){
      //精选
      SiftConteroller.to.getDataList();
    }else if(value == 1){
      //市场
      MarketConteroller.to.getDataList();
    }else if(value == 2){
      //盲盒
      BoxConteroller.to.getDataList();
    }else if(value == 3){
      //我的
      MyConteroller.to.getDataList();

    }
    update([TabbarItemWidget]);
  }
}